home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.4 Applications 1997 August / SGI IRIX 6.4 Applications 1997 August.iso / dist / dynaweb.idb / usr / lib / Insight / dweb / cgi-bin / cgi_info.pl.z / cgi_info.pl
Encoding:
Perl Script  |  1997-07-30  |  1.3 KB  |  47 lines

  1. #!/usr/free/bin/perl
  2. # Script to output CGI Information
  3. # From "Spinning the Web" by Andrew Ford, p 155.
  4.  
  5. # Output to MIME headers and HTML document head
  6.  
  7. print("Content-Type: text/html\n\n");
  8. print("<HEAD><TITLE>CGI Information Received</TITLE>\n");
  9. print("</HEAD><BODY><H1>CGI Information Received</H1>\n");
  10.  
  11. # Output the values of environment variables
  12.  
  13. print("<H2>Environment Variables</H2>\n<DL COMPACT>\n");
  14. foreach $var ("GATEWAY_INTERFACE", "REQUEST_METHOD",
  15.           "CONTENT_TYPE",      "CONTENT_LENGTH",
  16.           "SCRIPT_NAME",       "PATH_INFO",
  17.           "PATH_TRANSLATED",   "QUERY_STRING",
  18.           "REMOTE_HOST",       "REMOTE_ADDR",
  19.           "REMOTE_USER",       "REMOTE_IDENT",
  20.           "SERVER_NAME",       "SERVER_PORT",
  21.           "SERVER_SOFTWARE",   "SERVER_PROTOCOL",
  22.           "AUTH_TYPE",         "PATH", "HTTP_ACCEPT")
  23. {
  24.   print("<DT><B>$var</B><DD>$ENV{$var}\n");
  25. }
  26. print("</DL>\n");
  27.  
  28. #Output any command line arguments
  29.  
  30. if ($#ARGV > 0) {
  31.   print("<H2>Command Line Arguments</H2>\n");
  32.   foreach $i (0 .. $#ARGV) {
  33.     printf("ARGv[$i]: %s<BR>\n", $ARGV[$i]);
  34.   }
  35. }
  36.  
  37. # Output any data on the standard input stream
  38.  
  39. if ($ENV{CONTENT_LENGTH} ne "") {
  40.   read(STDIN, $content, $ENV{CONTENT_LENGTH});
  41.   print("<H2>Data on Standard Input</H2>\n");
  42.   print("<PRE>$content</PRE>\n");
  43. }
  44.  
  45. print("</BODY>\n");
  46.  
  47.